Optimal. Leaf size=65 \[ \frac {2 a b \tanh ^{-1}\left (\frac {a+b \tan \left (\frac {x}{2}\right )}{\sqrt {a^2-b^2}}\right )}{\left (a^2-b^2\right )^{3/2}}-\frac {\sec (x) (b-a \sin (x))}{a^2-b^2} \]
[Out]
________________________________________________________________________________________
Rubi [A] time = 0.14, antiderivative size = 65, normalized size of antiderivative = 1.00, number of steps used = 6, number of rules used = 6, integrand size = 13, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.462, Rules used = {3872, 2866, 12, 2660, 618, 206} \[ \frac {2 a b \tanh ^{-1}\left (\frac {a+b \tan \left (\frac {x}{2}\right )}{\sqrt {a^2-b^2}}\right )}{\left (a^2-b^2\right )^{3/2}}-\frac {\sec (x) (b-a \sin (x))}{a^2-b^2} \]
Antiderivative was successfully verified.
[In]
[Out]
Rule 12
Rule 206
Rule 618
Rule 2660
Rule 2866
Rule 3872
Rubi steps
\begin {align*} \int \frac {\sec ^2(x)}{a+b \csc (x)} \, dx &=\int \frac {\sec (x) \tan (x)}{b+a \sin (x)} \, dx\\ &=-\frac {\sec (x) (b-a \sin (x))}{a^2-b^2}-\frac {\int \frac {a b}{b+a \sin (x)} \, dx}{a^2-b^2}\\ &=-\frac {\sec (x) (b-a \sin (x))}{a^2-b^2}-\frac {(a b) \int \frac {1}{b+a \sin (x)} \, dx}{a^2-b^2}\\ &=-\frac {\sec (x) (b-a \sin (x))}{a^2-b^2}-\frac {(2 a b) \operatorname {Subst}\left (\int \frac {1}{b+2 a x+b x^2} \, dx,x,\tan \left (\frac {x}{2}\right )\right )}{a^2-b^2}\\ &=-\frac {\sec (x) (b-a \sin (x))}{a^2-b^2}+\frac {(4 a b) \operatorname {Subst}\left (\int \frac {1}{4 \left (a^2-b^2\right )-x^2} \, dx,x,2 a+2 b \tan \left (\frac {x}{2}\right )\right )}{a^2-b^2}\\ &=\frac {2 a b \tanh ^{-1}\left (\frac {a+b \tan \left (\frac {x}{2}\right )}{\sqrt {a^2-b^2}}\right )}{\left (a^2-b^2\right )^{3/2}}-\frac {\sec (x) (b-a \sin (x))}{a^2-b^2}\\ \end {align*}
________________________________________________________________________________________
Mathematica [A] time = 0.35, size = 97, normalized size = 1.49 \[ \frac {2 a b \tan ^{-1}\left (\frac {a+b \tan \left (\frac {x}{2}\right )}{\sqrt {b^2-a^2}}\right )}{\left (b^2-a^2\right )^{3/2}}+\sin \left (\frac {x}{2}\right ) \left (\frac {1}{(a-b) \left (\sin \left (\frac {x}{2}\right )+\cos \left (\frac {x}{2}\right )\right )}+\frac {1}{(a+b) \left (\cos \left (\frac {x}{2}\right )-\sin \left (\frac {x}{2}\right )\right )}\right ) \]
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
fricas [A] time = 0.67, size = 243, normalized size = 3.74 \[ \left [-\frac {\sqrt {a^{2} - b^{2}} a b \cos \relax (x) \log \left (-\frac {{\left (a^{2} - 2 \, b^{2}\right )} \cos \relax (x)^{2} + 2 \, a b \sin \relax (x) + a^{2} + b^{2} - 2 \, {\left (b \cos \relax (x) \sin \relax (x) + a \cos \relax (x)\right )} \sqrt {a^{2} - b^{2}}}{a^{2} \cos \relax (x)^{2} - 2 \, a b \sin \relax (x) - a^{2} - b^{2}}\right ) + 2 \, a^{2} b - 2 \, b^{3} - 2 \, {\left (a^{3} - a b^{2}\right )} \sin \relax (x)}{2 \, {\left (a^{4} - 2 \, a^{2} b^{2} + b^{4}\right )} \cos \relax (x)}, \frac {\sqrt {-a^{2} + b^{2}} a b \arctan \left (-\frac {\sqrt {-a^{2} + b^{2}} {\left (b \sin \relax (x) + a\right )}}{{\left (a^{2} - b^{2}\right )} \cos \relax (x)}\right ) \cos \relax (x) - a^{2} b + b^{3} + {\left (a^{3} - a b^{2}\right )} \sin \relax (x)}{{\left (a^{4} - 2 \, a^{2} b^{2} + b^{4}\right )} \cos \relax (x)}\right ] \]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
giac [A] time = 0.77, size = 95, normalized size = 1.46 \[ -\frac {2 \, {\left (\pi \left \lfloor \frac {x}{2 \, \pi } + \frac {1}{2} \right \rfloor \mathrm {sgn}\relax (b) + \arctan \left (\frac {b \tan \left (\frac {1}{2} \, x\right ) + a}{\sqrt {-a^{2} + b^{2}}}\right )\right )} a b}{{\left (a^{2} - b^{2}\right )} \sqrt {-a^{2} + b^{2}}} - \frac {2 \, {\left (a \tan \left (\frac {1}{2} \, x\right ) - b\right )}}{{\left (a^{2} - b^{2}\right )} {\left (\tan \left (\frac {1}{2} \, x\right )^{2} - 1\right )}} \]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
maple [A] time = 0.44, size = 92, normalized size = 1.42 \[ -\frac {4}{\left (4 a -4 b \right ) \left (\tan \left (\frac {x}{2}\right )+1\right )}-\frac {2 a b \arctan \left (\frac {2 \tan \left (\frac {x}{2}\right ) b +2 a}{2 \sqrt {-a^{2}+b^{2}}}\right )}{\left (a -b \right ) \left (a +b \right ) \sqrt {-a^{2}+b^{2}}}-\frac {4}{\left (4 a +4 b \right ) \left (\tan \left (\frac {x}{2}\right )-1\right )} \]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
maxima [F(-2)] time = 0.00, size = 0, normalized size = 0.00 \[ \text {Exception raised: ValueError} \]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
mupad [B] time = 0.40, size = 104, normalized size = 1.60 \[ \frac {\frac {2\,b}{a^2-b^2}-\frac {2\,a\,\mathrm {tan}\left (\frac {x}{2}\right )}{a^2-b^2}}{{\mathrm {tan}\left (\frac {x}{2}\right )}^2-1}+\frac {2\,a\,b\,\mathrm {atanh}\left (\frac {2\,a^3-2\,a\,b^2+2\,b\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (a^2-b^2\right )}{2\,{\left (a+b\right )}^{3/2}\,{\left (a-b\right )}^{3/2}}\right )}{{\left (a+b\right )}^{3/2}\,{\left (a-b\right )}^{3/2}} \]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
sympy [F] time = 0.00, size = 0, normalized size = 0.00 \[ \int \frac {\sec ^{2}{\relax (x )}}{a + b \csc {\relax (x )}}\, dx \]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________